﻿using System;
using System.Collections.Generic;
using System.Text;
using DataAccess;
using Entities;

namespace Logic
{
	public class GenreBL
	{
		public bool Save(Genre entity)
		{
			GenreDAL dal = new GenreDAL();
			return dal.Save(entity);
		}

		public bool Update(Genre entity)
		{
			GenreDAL dal = new GenreDAL();
			return dal.Update(entity);
		}

		public bool Delete(Genre entity)
		{
			GenreDAL dal = new GenreDAL();
			return dal.Delete(entity);
		}

		public List<Genre> List()
		{
			GenreDAL dal = new GenreDAL();
			return dal.List();
		}

		public Genre GetByName(string name)
		{
			GenreDAL dal = new GenreDAL();
			return dal.GetByName(name);
		}

		public Genre GetLastAdded()
		{
			GenreDAL dal = new GenreDAL();
			return dal.GetLastAdded();
		}

		public List<Movie> GetMovies(Genre entity)
		{
			MovieDAL mdal = new MovieDAL();
			return mdal.List("SELECT movies.* FROM movies LEFT JOIN relationships ON movies.movie_id=relationships.movie_id WHERE relationships.relationship_element=" + entity.Id + " AND relationships.relationship_type='genre'");
		}
	}
}